require(['./config'], () => {
    require(['cookie', 'footer', 'service','jquery'], (cookie) => {
        class Index {
            constructor() {
                this.login()
            }
            login() {
                $('.enter').on('click', () => {
                    // console.log('123')
                    const name = $('.user').val(),
                        pwd = $('.pwd').val()
                    let userList = localStorage.getItem('userList')
                    if (userList) {
                        userList = JSON.parse(userList)
                        const isexist = userList.some(user => {
                            return user.name === name && user.pwd === pwd
                        })
                        if (isexist) {
                            $.cookie('name', name, {path:'/'})
                            alert('登陆成功 即将跳转首页')
                            // window.open('index.html')
                            // $.cookie('name', `{userList.name}`)
                            location.href = '/index.html'
                        } else {
                            alert('输入错误，请重新输入')
                        }
                    } else {
                        alert('请注册')
                        location.replace('/html/register.html')
                    }
                })
            }
        }
        new Index()
    })
})